import java.util.Arrays;
import java.util.Scanner;
public class hk6Q2try2
{
    public static void main(String[] args) 
    {
    //实验环境测试版
    /*int[] position = {0,1,2,3,4,5,6,7,8,9,10,11};
    System.out.println("The number's position is " + Arrays.toString(position) + "\t");
    int[] chase = {5,4,110,9,5,6,7,8,233,7,58,666};
    Arrays.sort(chase);
    System.out.println("-----------------------------------------------------------------------------");
    System.out.println("The ordered array is " + Arrays.toString(chase) + "\t");
    */
    Scanner input = new Scanner(System.in);
    System.out.println("Please load in the array's length");
    int len = input.nextInt();
    int[] chase = new int[len];
    int[] position = new int[len];
    for (int i = 0; i < len; i++) 
    {
        //int[] position = new int[len];
        System.out.println("Please load in the array's number");
        chase[i] = input.nextInt();
        position[i] = i;
    }
    Arrays.sort(chase);    
    //System.out.println("The number's position is " + Arrays.toString(position) + "\t");
    //System.out.println("The ordered arrary is " + Arrays.toString(chase) + "\t");
    System.out.println("Please load in the number you want to chase.");
    int commend = input.nextInt();
    int low = 0;
    int high = chase.length-1;
    int index = -1;
    int mid = 0;
    while (low <= high)
    {
        mid = (low + high) / 2;
        //int guess = chase[mid];
        if(chase[mid] == commend)
        {
            index = mid;
            break;
        }
        if(chase[mid] < commend)
        {
            low = mid + 1;
        }
        if(chase[mid] > commend)
        {
            high = mid - 1;
        }
    }
    System.out.println("-----------------------------------------------------------------------------");
    System.out.println("The number's position is " + Arrays.toString(position) + "\t");
    System.out.println("The ordered arrary is " + Arrays.toString(chase) + "\t");
    if (index != -1)
    {
        System.out.println("The number we're chase for is" + commend + "and its house lies in " + index);
    }
    else
    {
        System.out.println("The number is not found!");
    }
    //System.out.println("The number we're chase for is" + commend + "and its house lies in " + Arrays.binarySearch(chase, commend));
    input.close();
    }
}